//
// Created by francklinson on 2021/7/24 AT 23:01.
//
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

class Solution {
public:
    int largestPerimeter(vector<int> &nums) {
        sort(nums.begin(), nums.end());
        unsigned int N = nums.size();
        for (int i = N-1; i >=2 ; --i) {
            if (nums[i-2]+nums[i-1] > nums[i]){
                return nums[i-2]+nums[i-1] + nums[i];
            }
        }
        return 0;
    }
};

int main() {
    vector<int> nums{3, 2, 6, 3};
    Solution solution;
    cout << solution.largestPerimeter(nums) << endl;
    return 0;
}

